package BIOtest02;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 服务器端
 */
public class Server {
    public static void main(String[] args){
        System.out.println("=======服务器端");
        try {
            //注册一个端口
            ServerSocket ss = new ServerSocket(9000);
            //监听客户端是否传数据
            Socket socket = ss.accept();
            //生成输入流
            InputStream is = socket.getInputStream();
            //创建缓冲区
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            //从缓冲区读写数据
            String msg = null;
            while((msg=reader.readLine())!=null ){
                System.out.println(msg);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
